/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.woxthebox.draglistview.sample.untils;

import com.woxthebox.draglistview.sample.ResourceTable;
import com.woxthebox.draglistview.sample.bean.HorizontalBean;
import com.woxthebox.draglistview.sample.bean.ListBean;
import com.woxthebox.draglistview.utils.FinalStaticBean;

import java.util.ArrayList;
import java.util.List;

/**
 * DataUntils Data tools class
 *
 * @since 2021-04-19
 */
public class DataUntils {
    private static int flag = 0;
    private static int mTitleFlag = 1;

    /**
     * 获取当前Title的值
     *
     * @return 返回当前Title的值
     */
    public static int getmTitleFlag() {
        return mTitleFlag;
    }

    /**
     * 获取列表布局的数据源
     *
     * @return 返回个数为40的ListBena的集合
     */
    public static List<ListBean> getlistData() {
        List<ListBean> list = new ArrayList<>();

        for (int i = 0; i < FinalStaticBean.NUM_40; i++) {
            list.add(new ListBean(ResourceTable.Media_ic_launcher,FinalStaticBean.ITEM + i));
        }
        return list;
    }

    /**
     * 外部设置titleFlag数值
     *
     * @param titleNum 外部设置的数值
     */
    public static void setmTitleFlag(int titleNum) {
        mTitleFlag = titleNum;
    }

    /**
     * 初始化横向滑动布局的item个数为5
     *
     * @return 返回值为横向滑动布局的item集合
     */
    public static List<HorizontalBean> getHorizontalBean() {
        List<HorizontalBean> horizontalBeans = new ArrayList<>();
        for (int i = 1; i <= FinalStaticBean.NUM_5; i++) {
            horizontalBeans.add(new HorizontalBean(mTitleFlag, getListHorizontalBean()));
        }
        return horizontalBeans;
    }

    /**
     * 获取横向滑动布局的item布局的item布局
     *
     * @return 返回个数为15的ListBean的集合
     */
    public static List<ListBean> getListHorizontalBean() {
        mTitleFlag++;
        List<ListBean> listBeans = new ArrayList<>();
        for (int i = 0; i < FinalStaticBean.NUM_15; i++) {
            listBeans.add(new ListBean(ResourceTable.Media_ic_launcher, FinalStaticBean.ITEM + flag));
            flag++;
        }
        return listBeans;
    }

    /**
     * 添加一个横向滑动的Item
     *
     * @param listBeans
     *
     * @return 返回值为一个ListBean集合
     */
    public static List<ListBean> addListHorizontalBean(List<ListBean> listBeans) {
        listBeans.add(0, new ListBean(ResourceTable.Media_ic_launcher, FinalStaticBean.TEST + flag));
        flag++;
        return listBeans;
    }
}